\section{Network Simulation \& Network Design Exercise (Scenario II)}

\input{../../java_src/dist/datas/r4_1}

\subsection{Simulation and results}

\subsubsection{How to find the right number and size of batches?}
As we know, there are two ways to decrease the percentage of confidence interval: \emph{Increase the size of sample} and \emph{find a right batch size}.

In figure~\ref{dia:r4:a},~\ref{dia:r4:b},~\ref{dia:r4:c},~\ref{dia:r4:d},~\ref{dia:r4:e},~\ref{dia:r4:f},~\ref{dia:r4:g},~\ref{dia:r4:h}, I choose different size of batch and different arrival size to find the right one.

In these figures, we can find \emph{increase the size of sample} can decrease the percentage stability, but \emph{change the size of batch} can decrease the percentage instability.

After making these experiments, I finally choose the arrival size=\totalNetwork{} and the batch size = 5000 for the result.

\batchPica{}

\batchPicb{}

\batchPicc{}

\batchPicd{}

\batchPice{}

\batchPicf{}

\batchPicg{}

\batchPich{}

\subsubsection{Results\label{sec:r4:s1}}
Total number of arrivals(from all sources) is \emph{\totalNetwork}

Delay table~\ref{tab:networkDelay}, and the loss rate result is table~\ref{tab:networkLossRate}.
\begin{table}[htp]
  \hspace*{-62pt}
  \begin{tabular}{c|cccc}
  \hline
  Path & Mean Delay($\sampleUnit{}$) &Confidence Interval($\sampleUnit{}$) & Number of Batch& Size of Batch\\
  \hline
  \networkDelay{}
  \\
  \hline
  \end{tabular}
  \caption{The network's Delay time}
  \label{tab:networkDelay}
\end{table}

\begin{table}[htp]
  \hspace*{-42pt}
  \begin{tabular}{c|cccc}
  \hline
  Queue & Mean Loss Rate($\%$) &Confidence Interval($\%$)&Number of Batch& Size of Batch\\
  \hline
  \networkLossRate{}
  \\
  \hline
  \end{tabular}
  \caption{The network's Loss Rate}
  \label{tab:networkLossRate}
\end{table}

\subsection{Make Loss Rate to 1\%}
First, the default network value is figure~\ref{dia:r4:network:default}.
\begin{figure}[htp]
  \networkErlangMap{?}{?}{?}{?}{?}{?}{?}{?}{?}
  \caption{Default network with initialize input}
  \label{dia:r4:network:default}
\end{figure}

Because we should decrease the loss rate to 1\%, so I suppose the loss rate to 0\%. If its 0 is in every queue, we can use \emph{Burke’s Theorem}. So the network values can be calculated, please see the figure~\ref{dia:r4:network:zero}.
\begin{figure}[htp]
  \networkErlangMap{0.3}{0.2}{0.7}{0.7}{$0.3+0.25=0.55$}{$0.2+0.2=0.4$}{$0.55+0.4=0.95$}{0.8}{0.8}
  \caption{0\% loss rate network}
  \label{dia:r4:network:zero}
\end{figure}

\begin{align}
  1>\rho  &> 0 \\
  K       &\ge{} 5\\
  p_K     &= \frac{(1-\rho)\rho^K}{1-\rho^{K+1}} \\
  p_K     &\le{} 0.01\\
  t       &= p_K\\
  K       &= \frac{\ln{\frac{t}{1+(t-1)\rho}}}{\ln{\rho}}\\
  \frac{\partial{}K}{\partial{}\rho} &= \frac{1 - t}{t\rho - \rho + 1} - \frac{1}{\rho{}\ln{\rho}} > 0 \label{eq:krho}
\end{align}
Let's find the relationship between $\rho$ and $K$, please see~\eqref{eq:krho}, so the $K\propto{}\rho$.

OK, let's use the max $\rho=0.95$ and $p_K=0.01$ to calculate the approximate \emph{K}. And the $K=34.7685061147171$.

When get the basic K($=35$), I should run the program from queue=35.In order to make the 1\% loss rate more confidence, I choose the right arrival size(\totalNetwork{}) and batch size(5000), and it's the same with section~\ref{sec:r4:s1}. And the result is in the table~\ref{tab:r4:leastlossrate}.
\begin{table}[htp]
  \center
  \begin{tabular}{r|cc}
  \hline
  K & Max Mean Loss Rate(\%)&Upper Limit($=Mean\times{}(1+0.05)$\%)\\
  \hline
    35& 1.2208971193415612&1.28194197530864 \\
    36& 1.1743621399176942&1.23308024691358 \\
    37& 1.1089547325102879&1.1644024691358  \\
    38& 1.0345290004113526&1.08625545043192 \\
    39& 0.9695927601809954&1.01807239819005 \\
    40& 0.9391772932949412&0.986136157959688\\
    41& 0.8539366515837095&0.896633484162895\\
    42& 0.828868778280542 &0.870312217194569\\
  \hline
  \end{tabular}
  \caption{The 1\% Loss rate result}
  \label{tab:r4:leastlossrate}
\end{table}

So the minimum value for K is \emph{40}, because $0.986136157959688\%<1\%$.

